		TITLE	EXESTR - Copyright (c) SLR Systems 1994

		INCLUDE	MACROS


		PUBLIC	FLUSH_EXESTR


		.DATA

		EXTERNDEF	EXESTR_STRUCTURE:SEQ_STRUCT


		.CODE	PASS2_TEXT

		EXTERNDEF	MOVE_EAX_TO_FINAL_HIGH_WATER:PROC,RELEASE_SEGMENT:PROC


FLUSH_EXESTR	PROC
		;
		;IF ANY EXESTR DATA, FLUSH IT PLEASE
		;
		MOV	EDX,OFF EXESTR_STRUCTURE._SEQ_TABLE

		CMP	DPTR [EDX],0		;ANY DATA?
		JZ	L9$

		MOV	ECX,[EDX].SEQ_STRUCT._SEQ_PTR-SEQ_STRUCT._SEQ_TABLE
		;
		;ECX IS NUMBER OF BYTES TO WRITE
		;
L1$:
		MOV	EAX,[EDX]
		ADD	EDX,4

		;
		;IF ECX > PAGE_SIZE, WRITE PAGE_SIZE
		;
		PUSHM	EDX,ECX

		CMP	ECX,PAGE_SIZE
		JB	L2$
L15$:
		MOV	ECX,PAGE_SIZE
L2$:
		PUSHM	ECX,EAX
		CALL	MOVE_EAX_TO_FINAL_HIGH_WATER

		POP	EAX
		CALL	RELEASE_SEGMENT

		POPM	EAX,ECX,EDX
		SUB	ECX,EAX
		JNZ	L1$
L9$:
		RET

FLUSH_EXESTR	ENDP


		END

